One of the most flexible features in is the way it can generate
random numbers. There are only two functions used in random number
creation — rand
, and srand
.
srand
(See Page
), is used to set the seed
value that the numbers are produced from. Using the same seed value
each time will produce the same sequence of random numbers. You
should use srand(``clock'')
if you want a unique sequence.
rand
is the function that
actually produces the random values. You can choose many different
distributions, though the uniform and normal distributions are likely
to be of most use. A complete list of distributions is given on
Page
.